#!/usr/bin/python3
# -*- coding: UTF-8 -*-

from time import time
from app import App
from utils.tools import Tools
from utils.element import Element

import gol
gol._init()
from os import popen as osPopen, path as osPath  # 管道处理

# app基本信息
oAppInfo = {}


class Application(App):
    # 初始配置
    def __init__(self):
        global oAppInfo
        # python2 不支持 super().__init__()
        App().__init__()

        self._d = App()._d
        self.tool = Tools()
        oAppInfo = self._d.info

    def getMy(self):
        sTxt = "我的"
        bEffect = App().el2("t",sTxt)
        self.echo(sTxt, bEffect)

    def getClockIn(self):
        sTxt = "签到"
        bEffect = App().el2("t",sTxt)
        self.echo(sTxt, bEffect)

    # ////////-----------------
    def getTTLXJ(self):
        App().getNode("t", "天天领现金")
        App().getNode("t", "可收取")
        App().getNode("t", "赚钱任务")
        self.TTLXJms()
        
    def TTLXJms(self):
        bNode = App()._d(text="浏览秒杀专区")
        if (bNode):
            bNode.right(text="去完成")
        print(bNode.info)
        # App().echo("浏览秒杀专区", bNode)
        # if (bNode):
        #     App()._d.press("back")
    
    # ////////-----------------





    # ////////-----------------
    def getWHCenter(self):
        global oAppInfo
        y = oAppInfo.displayHeight // 2
        x = oAppInfo.displayWidth // 2
        return (x, y)

    def startApp(self):
        sApp = 'com.jd.jdlite'
        self.tool.callApp(sApp)

    def killApp(self):
        App()._d.app_stop_all()
        self.tool.setSleep(3)


class Action(App):
    # 初始配置
    def __init__(self):
        # python2 不支持 super().__init__()
        App().__init__()
        self.tool = Tools()
        self.app = Application()
        self._d = App()._d

    def init(self):
        sAction = App().sAction
        if (sAction=='go'):
            self.app.TTLXJms()




action = Action()
action.init()
